<html>
<head>
<script type="text/javascript" src="counter.js"></script>
</head>

<body>

<form>
<input type="button" value="开始计时！" id="b1" switch="close">
<input type="text" id="txt">
</form>

<p>请点击上面的“开始计时”按钮来启动计时器。输入框会一直进行计时，从 0 开始。点击“停止计时”按钮可以终止计时，并将计数重置为 0。</p>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
    $(document).ready(function(){
        var $button = $('#b1');
        $button.click(function () {
            var switch1 =  $button.attr('switch');
            if (switch1 == 'close') {
                timedCount();
                $button.attr('switch', 'open');
            } else if (switch1 == 'open') {
                $button.attr('switch', 'close');
                stopCount();
            }
        });
    });
</script>
</body>

</html>
